package com.itheima.reggie.mapper;

import com.itheima.reggie.dto.SetmealDto;
import com.itheima.reggie.entity.Setmeal;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Set;

public interface SetmealMapper {
    @Select("select count(*) from setmeal where category_id=#{categoryId}")
    Integer selectCountByCategoryId(Long categoryId);
    //分页展现
    List<SetmealDto> selectAll(@Param("name") String name);
    //添加套餐
    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},1,#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    Integer addSetmeal(SetmealDto setmealDto);
    //通过id查找指定套餐
    @Select("select * from setmeal where id=#{id}")
    Setmeal findById(Long id);
    //更新套餐信息
    Integer update(SetmealDto setmealDto);
    //多选修改出售状态
    Integer updateStatus(@Param("status") Integer status,@Param("ids") Long[] ids);
    //多选删除套餐
    Integer delete(@Param("ids") Long[] ids);
    //通过categoryId查找指定套餐信息
    @Select("select  * from setmeal where category_id=#{categoryId} and status=#{status}")
    List<SetmealDto> findByCategoryIdAndStatus(Long categoryId,Integer status);




}
